﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace IntoTheme.Converters
{
    [ValueConversion(typeof(bool), typeof(Visibility))]
    public class VisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if ((bool)value)
                return Visibility.Visible;
            else
                return Visibility.Collapsed;
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (Visibility.Visible == (Visibility)value)
                return true;
            else
                return false;
        }
    }

    [ValueConversion(typeof(int), typeof(Visibility))]
    public class VisibilityByInt : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (System.Convert.ToInt32(value) == System.Convert.ToInt32(parameter))
                return Visibility.Visible;
            else
                return Visibility.Collapsed;
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (Visibility.Visible == (Visibility)value)
                return true;
            else
                return false;
        }
    }
}
